<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绿能充 - 充电桩详情</title>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        /* 原有样式保持不变... */
        :root {
            --primary-color: #00a896;
            --secondary-color: #02c39a;
            --dark-color: #05668d;
            --light-color: #f0f3bd;
            --accent-color: #028090;
            --text-dark: #333;
            --text-light: #f8f9fa;
            --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Noto Sans SC', sans-serif;
            color: var(--text-dark);
            background-color: #f9f9f9;
            min-height: 100vh;
            display: flex;
        }

        /* 侧边栏样式 - 与列表页面完全一致 */
        .sidebar {
            width: 250px;
            background: linear-gradient(135deg, var(--dark-color) 0%, var(--primary-color) 100%);
            color: white;
            padding: 20px 0;
            height: 100vh;
            position: fixed;
            box-shadow: var(--shadow);
            z-index: 100;
        }

        .sidebar-header {
            padding: 0 20px 20px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            margin-bottom: 20px;
        }

        .sidebar-header .logo {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }

        .sidebar-header .logo-icon {
            width: 40px;
            height: 40px;
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 18px;
            color: var(--light-color);
        }

        .sidebar-header h3 {
            font-size: 1.2rem;
            font-weight: 500;
            margin: 0;
        }

        .sidebar-header p {
            font-size: 0.8rem;
            opacity: 0.8;
            margin: 0;
        }

        .nav-menu {
            list-style: none;
            padding: 0 15px;
        }

        .nav-item {
            margin-bottom: 5px;
        }

        .nav-link {
            display: flex;
            align-items: center;
            padding: 12px 15px;
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
            border-radius: 8px;
            transition: var(--transition);
        }

        .nav-link:hover, .nav-link.active {
            background-color: rgba(255, 255, 255, 0.1);
            color: white;
        }

        .nav-link i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
            font-size: 16px;
        }

        .user-profile {
            position: absolute;
            bottom: 20px;
            left: 0;
            width: 100%;
            padding: 0 20px;
        }

        .user-info {
            display: flex;
            align-items: center;
            padding: 10px;
            background-color: rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            cursor: pointer;
            transition: var(--transition);
        }

        .user-info:hover {
            background-color: rgba(255, 255, 255, 0.2);
        }

        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 14px;
        }

        .user-name {
            font-size: 0.9rem;
            font-weight: 500;
            margin-bottom: 2px;
        }

        .user-role {
            font-size: 0.7rem;
            opacity: 0.8;
        }

        /* 主内容区样式 */
        .main-content {
            flex: 1;
            margin-left: 250px;
            padding: 30px;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }

        .page-title h1 {
            font-size: 1.8rem;
            font-weight: 600;
            color: var(--dark-color);
            margin-bottom: 5px;
        }

        .page-title p {
            color: #777;
            font-size: 0.9rem;
            margin: 0;
        }

        .header-actions {
            display: flex;
            gap: 10px;
        }

        .btn {
            padding: 8px 16px;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: 500;
            border: none;
            cursor: pointer;
            transition: var(--transition);
            display: flex;
            align-items: center;
        }

        .btn i {
            margin-right: 6px;
        }

        .btn-primary {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            color: white;
            box-shadow: 0 4px 15px rgba(0, 168, 150, 0.3);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(0, 168, 150, 0.4);
        }

        .btn-outline {
            background: transparent;
            border: 1px solid #ddd;
            color: #555;
        }

        .btn-outline:hover {
            background-color: #f5f5f5;
        }

        /* 详情卡片样式 */
        .detail-card {
            background-color: white;
            border-radius: 12px;
            box-shadow: var(--shadow);
            padding: 30px;
            margin-bottom: 20px;
            transition: var(--transition);
            position: relative;
            overflow: hidden;
        }

        .detail-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }

        .detail-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
        }

        .detail-header {
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .detail-header h3 {
            font-size: 1.3rem;
            font-weight: 600;
            margin: 0;
            color: var(--dark-color);
        }

        .detail-badge {
            display: inline-block;
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 500;
        }

        .badge-success {
            background-color: #e8f5e9;
            color: #4caf50;
        }

        .badge-warning {
            background-color: #fff8e1;
            color: #ff9800;
        }

        .badge-danger {
            background-color: #ffebee;
            color: #f44336;
        }

        .badge-secondary {
            background-color: #e0e0e0;
            color: #616161;
        }

        .badge-info {
            background-color: #e3f2fd;
            color: #2196f3;
        }

        .detail-section {
            margin-bottom: 30px;
        }

        .detail-section h4 {
            font-size: 1.1rem;
            margin-bottom: 15px;
            color: var(--dark-color);
            padding-bottom: 8px;
            border-bottom: 1px solid #eee;
        }

        .detail-row {
            display: flex;
            margin-bottom: 15px;
        }

        .detail-label {
            width: 120px;
            font-weight: 500;
            color: #666;
        }

        .detail-value {
            flex: 1;
        }

        .detail-actions {
            display: flex;
            justify-content: flex-end;
            gap: 15px;
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #eee;
        }

        /* 地图容器样式 */
        .map-container {
            height: 300px;
            background-color: #f5f5f5;
            border-radius: 8px;
            margin-top: 15px;
            overflow: hidden;
            border: 1px solid #ddd;
        }

        /* 响应式设计 */
        @media (max-width: 992px) {
            .sidebar {
                width: 70px;
                overflow: hidden;
            }

            .sidebar-header h3,
            .sidebar-header p,
            .nav-link span,
            .user-name,
            .user-role {
                display: none;
            }

            .sidebar-header {
                padding: 15px 10px;
            }

            .nav-link {
                justify-content: center;
                padding: 12px 0;
            }

            .nav-link i {
                margin-right: 0;
                font-size: 18px;
            }

            .main-content {
                margin-left: 70px;
            }
        }

        @media (max-width: 768px) {
            .detail-row {
                flex-direction: column;
            }
            .detail-label {
                width: 100%;
                margin-bottom: 5px;
            }
            .header {
                flex-direction: column;
                align-items: flex-start;
                gap: 15px;
            }
        }

        @media (max-width: 576px) {
            .main-content {
                padding: 20px 15px;
            }
            .detail-actions {
                flex-direction: column;
            }
            .btn {
                width: 100%;
                justify-content: center;
            }
        }
        /* 新增地图相关样式 */
        .map-container {
            height: 300px;
            background-color: #f5f5f5;
            border-radius: 8px;
            margin-top: 15px;
            overflow: hidden;
            border: 1px solid #ddd;
            position: relative;
        }

        .map-placeholder {
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: #999;
            background-color: #e6f7ff;
        }

        .map-marker {
            position: absolute;
            width: 24px;
            height: 24px;
            background-color: var(--primary-color);
            border-radius: 50%;
            border: 3px solid white;
            transform: translate(-50%, -50%);
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
            z-index: 10;
        }

        .map-marker::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 50%;
            width: 0;
            height: 0;
            border-left: 6px solid transparent;
            border-right: 6px solid transparent;
            border-top: 10px solid var(--primary-color);
            transform: translateX(-50%);
        }

        .map-coordinates {
            position: absolute;
            bottom: 10px;
            left: 10px;
            background-color: rgba(255,255,255,0.9);
            padding: 5px 10px;
            border-radius: 4px;
            font-size: 12px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            z-index: 100;
        }
    </style>
</head>
<body>
<!-- 侧边导航栏 - 与列表页面完全一致 -->
<div class="sidebar">
    <div class="sidebar-header">
        <div class="logo">
            <div class="logo-icon">
                <i class="fas fa-charging-station"></i>
            </div>
            <div>
                <h3>绿能充</h3>
                <p>管理员面板</p>
            </div>
        </div>
    </div>

    <ul class="nav-menu">
        <li class="nav-item">
            <a href="/admin/dashboard" class="nav-link">
                <i class="fas fa-tachometer-alt"></i>
                <span>仪表盘</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/user/list" class="nav-link">
                <i class="fas fa-users"></i>
                <span>用户管理</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/pile/list" class="nav-link active">
                <i class="fas fa-charging-station"></i>
                <span>充电桩管理</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/announcement/list" class="nav-link">
                <i class="fas fa-bullhorn"></i>
                <span>公告管理</span>
                <span class="badge">2</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/report/list" class="nav-link">
                <i class="fas fa-list-alt"></i>
                <span>充电记录</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/fault/list" class="nav-link">
                <i class="fas fa-exclamation-triangle"></i>
                <span>故障报告</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/settings" class="nav-link">
                <i class="fas fa-cog"></i>
                <span>系统设置</span>
            </a>
        </li>
    </ul>

    <div class="user-profile">
        <div class="user-info">
            <div class="user-avatar">
                <i class="fas fa-user"></i>
            </div>
            <div>
                <div class="user-name">管理员</div>
                <div class="user-role">超级管理员</div>
            </div>
        </div>
    </div>
</div>

<!-- 主内容区 -->
<div class="main-content">
    <div class="header">
        <div class="page-title">
            <h1>充电桩详情</h1>
            <p>查看充电桩详细信息</p>
        </div>
        <div class="header-actions">
            <a href="${pageContext.request.contextPath}/admin/pile/list" class="btn btn-outline">
                <i class="fas fa-arrow-left"></i> 返回列表
            </a>
        </div>
    </div>

    <!-- 详情卡片 -->
    <div class="detail-card">
        <div class="detail-header">
            <h3>${pile.name}</h3>
            <span class="detail-badge ${pile.status == 'AVAILABLE' ? 'badge-success' :
                                      pile.status == 'CHARGING' ? 'badge-warning' :
                                      pile.status == 'FAULT' ? 'badge-danger' : 'badge-secondary'}">
                ${pile.status == 'AVAILABLE' ? '可用' :
                        pile.status == 'CHARGING' ? '充电中' :
                                pile.status == 'FAULT' ? '故障' : '维护中'}
            </span>
        </div>

        <!-- 基本信息部分 -->
        <div class="detail-section">
            <h4><i class="fas fa-info-circle"></i> 基本信息</h4>
            <div class="detail-row">
                <div class="detail-label">充电桩编号</div>
                <div class="detail-value">${pile.code}</div>
            </div>
            <div class="detail-row">
                <div class="detail-label">充电桩名称</div>
                <div class="detail-value">${pile.name}</div>
            </div>
            <div class="detail-row">
                <div class="detail-label">充电类型</div>
                <div class="detail-value">
                    <span class="detail-badge ${pile.type == 'DC' ? 'badge-info' : 'badge-secondary'}">
                        ${pile.type == 'DC' ? '直流快充' : '交流慢充'}
                    </span>
                </div>
            </div>
            <div class="detail-row">
                <div class="detail-label">功率</div>
                <div class="detail-value">${pile.power} kW</div>
            </div>
            <div class="detail-row">
                <div class="detail-label">价格</div>
                <div class="detail-value">${pile.price} 元/度</div>
            </div>
        </div>

        <!-- 位置信息部分 -->
        <div class="detail-section">
            <h4><i class="fas fa-map-marker-alt"></i> 位置信息</h4>
            <div class="detail-row">
                <div class="detail-label">详细地址</div>
                <div class="detail-value">${pile.location}</div>
            </div>
            <div class="detail-row">
                <div class="detail-label">坐标</div>
                <div class="detail-value">
                    <c:if test="${not empty pile.latitude and not empty pile.longitude}">
                        纬度: ${pile.latitude}, 经度: ${pile.longitude}
                    </c:if>
                    <c:if test="${empty pile.latitude or empty pile.longitude}">
                        未设置坐标
                    </c:if>
                </div>
            </div>
            <div class="map-container" id="mapContainer">
                <c:choose>
                    <c:when test="${not empty pile.latitude and not empty pile.longitude}">
                        <div id="map" style="width:100%;height:100%;"></div>
                        <div class="map-coordinates">
                            充电桩位置: ${pile.latitude}, ${pile.longitude}
                        </div>
                        <div class="map-marker" id="pileMarker"></div>
                    </c:when>
                    <c:otherwise>
                        <div class="map-placeholder">
                            <i class="fas fa-map-marked-alt" style="font-size: 2rem; margin-bottom: 10px;"></i>
                            <span>该充电桩未设置地理位置信息</span>
                        </div>
                    </c:otherwise>
                </c:choose>
            </div>
        </div>

        <!-- 运营信息部分 -->
        <div class="detail-section">
            <h4><i class="fas fa-chart-line"></i> 运营信息</h4>
            <div class="detail-row">
                <div class="detail-label">运营商</div>
                <div class="detail-value">${not empty pile.operator ? pile.operator : '未设置'}</div>
            </div>
            <div class="detail-row">
                <div class="detail-label">生产厂家</div>
                <div class="detail-value">${not empty pile.manufacturer ? pile.manufacturer : '未设置'}</div>
            </div>
            <div class="detail-row">
                <div class="detail-label">安装日期</div>
                <div class="detail-value">
                    <c:if test="${not empty pile.installDate}">
                        <fmt:formatDate value="${pile.installDate}" pattern="yyyy-MM-dd"/>
                    </c:if>
                    <c:if test="${empty pile.installDate}">
                        未设置
                    </c:if>
                </div>
            </div>
            <div class="detail-row">
                <div class="detail-label">最近维护</div>
                <div class="detail-value">
                    <c:if test="${not empty pile.lastMaintenanceDate}">
                        <fmt:formatDate value="${pile.lastMaintenanceDate}" pattern="yyyy-MM-dd"/>
                    </c:if>
                    <c:if test="${empty pile.lastMaintenanceDate}">
                        未记录
                    </c:if>
                </div>
            </div>
        </div>

        <!-- 其他信息部分 -->
        <div class="detail-section">
            <h4><i class="fas fa-ellipsis-h"></i> 其他信息</h4>
            <div class="detail-row">
                <div class="detail-label">描述信息</div>
                <div class="detail-value">${not empty pile.description ? pile.description : '无描述信息'}</div>
            </div>
            <div class="detail-row">
                <div class="detail-label">创建时间</div>
                <div class="detail-value">
                    <fmt:formatDate value="${pile.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
                </div>
            </div>
            <div class="detail-row">
                <div class="detail-label">更新时间</div>
                <div class="detail-value">
                    <fmt:formatDate value="${pile.updateTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
                </div>
            </div>
        </div>

        <!-- 操作按钮 -->
        <div class="detail-actions">
            <a href="${pageContext.request.contextPath}/admin/pile/edit/${pile.id}" class="btn btn-primary">
                <i class="fas fa-edit"></i> 编辑
            </a>
            <a href="${pageContext.request.contextPath}/admin/pile/list" class="btn btn-outline">
                <i class="fas fa-list"></i> 返回列表
            </a>
        </div>
    </div>
</div>


<script>
    document.addEventListener('DOMContentLoaded', function() {
        <c:if test="${not empty pile.latitude and not empty pile.longitude}">
        // 充电桩坐标
        const pileLat = ${pile.latitude};
        const pileLng = ${pile.longitude};

        // 初始化简单地图
        function initSimpleMap() {
            const mapContainer = document.getElementById('mapContainer');
            mapContainer.innerHTML = `
            <div id="map" style="width:100%;height:100%;position:relative;background:#e6f7ff;"></div>
            <div class="map-coordinates">
                充电桩位置: ${pile.latitude}, ${pile.longitude}
            </div>
            <div class="map-marker" id="pileMarker" style="top:50%;left:50%;"></div>
        `;

            // 可以添加简单的拖动效果（可选）
            const map = document.getElementById('map');
            const marker = document.getElementById('pileMarker');
            let isDragging = false;
            let offsetX = 0, offsetY = 0;

            map.addEventListener('mousedown', (e) => {
                isDragging = true;
                map.style.cursor = 'grabbing';
            });

            document.addEventListener('mousemove', (e) => {
                if (!isDragging) return;
                offsetX = e.movementX;
                offsetY = e.movementY;
                marker.style.transform = `translate(-50%, -50%) translate(${offsetX}px, ${offsetY}px)`;
            });

            document.addEventListener('mouseup', () => {
                isDragging = false;
                map.style.cursor = 'grab';
            });
        }

        initSimpleMap();
        </c:if>
    });
</script>
</body>
</html>